﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Configuration.ModelConfiguration;
using Microsoft.Data.Objects;

namespace Configuration
{
    public class DatabaseFactory
    {
        public Database Context { get; set; }

        public DatabaseFactory()
        {
            var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);

            var builder = new ContextBuilder<Database>();

            Registerconfig(builder);

            Context = builder.Create(conn);
        }

        static void Registerconfig(ContextBuilder<Database> builder)
        {
            builder.Configurations.Add(new UserConfiguration());

            builder.Configurations.Add(new ProductConfiguration());

            builder.Configurations.Add(new CategoryConfiguration());
        }
    }
}
